package com.brillilab.common.alioss;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author zlb
 * @Title: OssFileEnum
 * @ProjectName brill_lab
 * @Description: TODO
 * @date 2019/5/9 15:51
 */
@Getter
@AllArgsConstructor
public enum OssFileEnum {
    /**
     * 附件类型(100实验，200试剂，300公告，400方法 ,500课题，600仪器,700用户,800其它)
     */
    //实验相关
    Experiment(100, "Experiment", false,OssFilePrivilegeEnum.Lab,false),
    TipFile(101, "TipFile", false,OssFilePrivilegeEnum.Lab,false),//tip文件
    CommentFile(102, "CommentFile", false,OssFilePrivilegeEnum.Lab,false),//评论文件
    //实验结果相关
    AnalyzeDataFile(103, "AnalyzeData", true,OssFilePrivilegeEnum.Lab,false),//分析后数据
    PrimaryDataFile(104, "PrimaryData", true,OssFilePrivilegeEnum.Lab,false),//原始数据
    AuditFile(105, "AuditFile", false,OssFilePrivilegeEnum.Lab,false),//审核文件
    RemarksDataFile(106, "RemarksDataFile", false,OssFilePrivilegeEnum.Lab,false),//现象备注文件
    AnalyzeDataFileThumbnail(107, "AnalyzeDataFileThumbnail", true,OssFilePrivilegeEnum.Lab,false),//分析后缩略图


    //试剂
    Reagent(200, "reagent", false,OssFilePrivilegeEnum.Lab,false),
    KitInstructionFile(201, "KitInstruction", false,OssFilePrivilegeEnum.Lab,false),//Kit说明书
    ReagentInstructionFile(202, "ReagentInstruction", false,OssFilePrivilegeEnum.Lab,false),//试剂说明书
    SampleAttrFile(203, "SampleAttr", false,OssFilePrivilegeEnum.Lab,false),//样品属性
    PlasmidAbstractFile(204, "PlasmidAbstract", false,OssFilePrivilegeEnum.Lab,false),//序列文摘
    PlasmidAtlasFile(205, "PlasmidAtlas", false,OssFilePrivilegeEnum.Lab,false),//图谱链接
    PlasmidReportFile(206, "PlasmidReport", false,OssFilePrivilegeEnum.Lab,false),//测序报告
    PlasmidOtherFile(207, "PlasmidOther", false,OssFilePrivilegeEnum.Lab,false),//其他链接

    //公告
    Announcement(300, "Announcement", false,OssFilePrivilegeEnum.Lab,false),

    //方法
    Method(400, "Method", false,OssFilePrivilegeEnum.Person,false),
    PublicMethod(401, "PublicMethod", false,OssFilePrivilegeEnum.Public,true), //公有方法

    //课题
    Topic(500, "Topic", true,OssFilePrivilegeEnum.Lab,false),
    TopicProjectPlanFile(501, "TopicProjectPlan", true,OssFilePrivilegeEnum.Lab,false),//项目计划书
    TopicProjectBudgetFile(502, "TopicProjectBudget", true,OssFilePrivilegeEnum.Lab,false),//项目预算表
    TopicResultDataFile(503, "TopicResultData", true,OssFilePrivilegeEnum.Lab,false),//研究内容-结果数据
    TopicRepresentativeWorksFile(504, "TopicRepresentativeWorks", true,OssFilePrivilegeEnum.Lab,false),//代表性论著
    TopicPatentFile(505, "TopicPatent", true,OssFilePrivilegeEnum.Lab,false),//专利文档
    TopicOtherFile(506, "TopicOther", true,OssFilePrivilegeEnum.Lab,false),//其他
   
    //仪器
    Instrument(600, "Instrument", false,OssFilePrivilegeEnum.Lab,false),

    //用户个人
    Person(700, "Person", false,OssFilePrivilegeEnum.Lab,false),
    PersonHeadImg(701, "PersonHeadImg", false,OssFilePrivilegeEnum.Public,true),
    CertificateImg(702, "CertificateImg", false,OssFilePrivilegeEnum.Person,false),//证件照
    LabLogo(703, "LabLogo", false,OssFilePrivilegeEnum.Public,true),//实验室头像

    //其它文件
    OtherFile(800, "OtherFile", false,OssFilePrivilegeEnum.Lab,false),
    VideoPreviewImg(801, "VideoPreviewImg", false,OssFilePrivilegeEnum.Public,true),//视频预览图
    PublicFile(802,"PublicFile",false,OssFilePrivilegeEnum.Public,true),//公共文件,
    PlanCommentFile(803, "PlanCommentFile", false,OssFilePrivilegeEnum.Lab,false),//实验计划评论文件
    ChatMessageFile(804, "ChatMessageFile", false,OssFilePrivilegeEnum.Lab,false),//聊天信息文件

    //TroubleShooting
    TroubleShooting(900, "TroubleShooting", false,OssFilePrivilegeEnum.Lab,false),
    TroubleShootingReason(901, "TroubleShootingReason", false,OssFilePrivilegeEnum.Lab,false),//原因
    TroubleShootingDeal(902, "TroubleShootingDeal", false,OssFilePrivilegeEnum.Lab,false),//解决方案

    CrmPayVoucher(1000, "CrmPayVoucher", false,OssFilePrivilegeEnum.Public,true);//打款凭证


    private Integer key;
    private String value;
    /**
     * 文件是否加密
     */
    private Boolean isEncrypt;
    /**
     * 文件存放类型（结合枚举OssFilePrivilegeEnum）
     */
    private OssFilePrivilegeEnum fileSaveType;

    /**
     * 是否为公有空间
     */
    private Boolean isPublicBucket;

    public static OssFileEnum getEnum(Integer key) {
        for (OssFileEnum e : OssFileEnum.values()) {
            if (e.getKey().equals(key)) return e;
        }
        return null;
    }

    public static String getValue(Integer key) {
        OssFileEnum e = getEnum(key);
        return e != null ? e.getValue() : null;
    }

    public static Boolean getIsEncrypt(Integer key) {
        OssFileEnum e = getEnum(key);
        return e != null ? e.getIsEncrypt() : null;
    }

    public static String getFileSaveType(Integer key) {
        OssFileEnum e = getEnum(key);
        return e != null ? e.getFileSaveType().getValue() : null;
    }

    public static Boolean getIsPublicBucket(Integer key) {
        OssFileEnum e = getEnum(key);
        return e != null ? e.getIsPublicBucket() : null;
    }
}
